Skip to content

[Issue #4108] fn_parameter_post_comment_alignment config option#6930

Draft
Ripper53 wants to merge 1 commit into
rust-lang:mainfrom
Ripper53:fn-parameter-post-comment-alignment-config
Draft

[Issue #4108] fn_parameter_post_comment_alignment config option#6930
Ripper53 wants to merge 1 commit into
rust-lang:mainfrom
Ripper53:fn-parameter-post-comment-alignment-config

Conversation

@Ripper53
Copy link
Copy Markdown

@Ripper53 Ripper53 commented May 27, 2026

Issue

Add config to format like from this issue: #4108

Currently, this code:

fn foo(
    a: usize, // Meow
    b: f32, // Bark
) {
}

Is formatted into this:

fn foo(
    a: usize, // Meow
    b: f32,   // Bark
) {
}

This can confuse the reader into thinking that the two comments are related or follow each other, even when they are unrelated.

Changes

Add a config option of fn_post_comment_alignment that has two options:

  1. SameIndent
  2. SingleSpace

The SameIndent option preserves the current behavior, while the SingleSpace is the new behavior.

To make the configuration highly customizable, the write_list function takes an additional PostCommentAlignment parameter now. This will allow different behavior in different places, like in match statements or imports.

@rustbot rustbot added the S-waiting-on-author Status: awaiting some action (such as code changes or more information) from the author. label May 27, 2026
@ytmimi
Copy link
Copy Markdown
Contributor

ytmimi commented May 27, 2026

I don't think it makes sense to support a bespoke fn_post_comment_alignment option just yet. It might make more sense to start with something more general to control post comment alignment in any list of items. For example, fn parameters, function call arguments, array literals, tuples, struct fields, etc.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

S-waiting-on-author Status: awaiting some action (such as code changes or more information) from the author.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants